#第一题，简单计数
l = [1, 2, 3, 4, 5]
for i in l:
    print(i)

for i, e in enumerate(l):
    print(f"index:{i}, value:{e}")

i = 0
while i <6:
    print(i)
    i += 1

i = 0
while True:
    if i == 100:
        break
    print(i)
    i += 1


#第二问，实现斐波那契函数
#for
a = 1
b = 1
c = 0
print(a, end=" ")
print(b, end=" ")
for i in range(3, 101):
    c = a + b
    a = b
    b = c
    print(c, end=" ")

#while
a = 1
b = 1
c = 0
i = 0
print(a, end=" ")
print(b, end=" ")
while i <= 100:
    c = a + b
    a = b
    b = c
    print(c, end=" ")
    i += 1

#第三问，自定义异常paramserror
class ParamsError (Exception):
    pass

print("请按以下数字选择你需要的运算：")
print("1、除法")
print("2、整除")
print("3、取余")


def div(a, b):
    try:
        return a / b
    except ZeroDivisionError:
        raise ParamsError("分母不可以为0！")
    finally:
        print("function my_sub end")

def ediv(a, b):
    try:
        return a // b
    except ZeroDivisionError:
        raise ParamsError("取整分母不可以为0！")
    finally:
        print("function my_sub end")

def rem(a, b):
    try:
        return a % b
    except ZeroDivisionError:
        raise ParamsError("取余分母不可以为0！")
    finally:
        print("function my_sub end")

C = input("请输入你需要的运算方法（1-3）：")
a = int(input("请输入第一个数字："))
b = int(input("请输入第二个数字："))
if C == '1':
    print(a, "/", b, "=", div(a, b))
elif C == '2':
    print(a, "//", b, "=", ediv(a, b))
elif C == '3':
    print(a, "%", b, "=", rem(a, b))
else:
    print("请在指定范围内进行选择！")















